package com.ling.sbbyyds.mapper.comment;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ling.sbbyyds.entity.comment.Comment;
import com.ling.sbbyyds.entity.comment.CommentLike;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 评论点赞表(SbbCommentLike)表数据库访问层
 *
 * @author ling
 * @since 2022-08-13 17:47:56
 */
@Mapper
public interface SbbCommentLikeDao extends BaseMapper<CommentLike> {

    /**
     * 获取用户是否点赞评论
     *
     * @param replyId 评论id
     * @param userId  用户id
     * @return
     */
    @Select("SELECT COUNT(id) FROM sbb_comment_like WHERE user_id = #{userId} AND comment_id = #{replyId} ")
    Integer isLikeReply(Long replyId, Long userId);

    /**
     * 获取用户是否点赞评论
     *
     * @param replyId 评论id
     * @return
     */
    @Select("SELECT id, like_count AS likeCount FROM sbb_comment WHERE id = #{replyId} ")
    Comment getReplyLikeNum(Long replyId);

}

